package com.example.demo.dto;

/**
 * 登录响应数据传输对象
 * 用于封装服务器返回的登录结果数据
 */
public class LoginResponse {
    private boolean success;
    private String message;
    private String username;

    // 无参构造函数
    public LoginResponse() {
    }

    // 带参构造函数
    public LoginResponse(boolean success, String message, String username) {
        this.success = success;
        this.message = message;
        this.username = username;
    }

    // 成功响应的静态工厂方法
    public static LoginResponse success(String username) {
        return new LoginResponse(true, "登录成功", username);
    }

    // 失败响应的静态工厂方法
    public static LoginResponse failure(String message) {
        return new LoginResponse(false, message, null);
    }

    // Getter和Setter方法
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}